<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏后台管理</title>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <!--<link href="__STATIC__/layui/css/layui.mobile.css/boot.css" rel="stylesheet">-->
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <style>
        th{
            text-align: center;
            vertical-align: middle!important;
        }
    </style>
</head>
<body>
    {include file="base/header" /}
    <div style="float: right; margin-top: 5px;margin-bottom: 5px" class="box-title ">
        <form class="form-inline" action="{:url('index/examine/index')}" method="get">
            <input type="text" name="title" value="" class="form-control" id="exampleInputEmail3" >
            <input type="submit" class="btn btn-default" value="搜索"/>
            <input type="button" onclick="res()" value="全部显示" class="btn btn-default"/>
        </form>
    </div>

    <table class="table table-bordered" style="width: 1300px;margin: 0 auto">
        <tr>
            <th>编号</th>
            <th>产品名称</th>
            <th>产品介绍</th>
            <th>分类</th>
            <!--<th>图片</th>-->
            <th>进货价</th>
            <th>统一零售价</th>
            <th>合作模式</th>
            <th>状态</th>

            <th>操作</th>
        </tr>
        {foreach $res as $val}
        <tr id="del{$val.id}" style="text-align: center">
            <td>{$val.id}</td>
            <td>{$val.pname}</td>
            <td>{$val.introduce|substr=###,0,10}</td>
            <td>{$val.category}</td>
            <!--<td>{$val.image|substr=###,0,10}</td>-->
            <td>{$val.purchaseprice}元</td>
            <td>{$val.retailprice}元</td>
            <td>{if $val.cooperation == 1} 进货价采购 {else/} 少量货物月结 {/if}</td>
            <td>{if $val.status == 3} 待审核 {/if}</td>
            <td>
                <!--<button onclick="del({$val.id})" type="button" class="btn btn-danger btn-xs">删除</button>-->
                <button onclick="through({$val.id})" type="button" class="btn btn-success btn-xs">通过</button>
                <button onclick="notthrough({$val.id})" type="button" class="btn btn-warning btn-xs">不通过</button>
                <button onclick="picture({$val.id})" type="button" class="btn btn-primary btn-xs" >查看图片</button>
            </td>
        </tr>
        {/foreach}
    </table>
    <div style="margin-left: 30px">{$res->render()}</div>
    </div>
</body>
<script>
    //审核通过
    function through(id) {
        layer.confirm('你确定要通过审核吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.ajax({
                url:"{:url('index/examine/through')}",
                type:"post",
                data: "id="+id,
                datatype:"json",
                success:function(data){
                    if(data.success){
                        layer.alert(data.success,{btn:['确定','取消']},function () {
                            window.location.reload();
                        },function () {
                            window.location.reload();
                        });
                    }else{
                        layer.alert(data.error);
                    }
                },
            });
        });
    }
    //不通过
    function notthrough(id){
        layer.confirm('你确定不通过审核吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.ajax({
                url:"{:url('index/examine/notthrough')}",
                type:"post",
                data: "id="+id,
                datatype:"json",
                success:function(data){
                    if(data.success){
                        layer.alert(data.success,{btn:['确定','取消']},function () {
                            window.location.reload();
                        },function () {
                            window.location.reload();
                        });
                    }else{
                        layer.alert(data.error);
                    }
                },
            });
        });

    }
    //显示所有
    function res() {
        window.location.href="{:url('index/examine/index')}";
    }

    function picture(id) {
        window.location.href="{:url('index/examine/image')}?id="+id;
    }

</script>
</html>